package com.onesports.intelligent.k12.polarlight.controller.operation.member;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.onesports.intelligent.k12.polarlight.common.utils.ResultUtil;
import com.onesports.intelligent.k12.polarlight.constant.ApiPathConstants;
import com.onesports.intelligent.k12.polarlight.domain.dto.sys.WxQueryDTO;
import com.onesports.intelligent.k12.polarlight.domain.vo.order.OrderByIdVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.student.StudentDetailVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.sys.WxQueryVO;
import com.onesports.intelligent.k12.polarlight.service.order.OrderService;
import com.onesports.intelligent.k12.polarlight.service.student.manage.PlatformMembershipService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author FPH
 * @since 2022年7月13日11:57:53
 */
@RestController
@Api(tags = "运营端-运营管理-平台会员")
@RequestMapping(ApiPathConstants.MEMBER)
@RequiredArgsConstructor
@PreAuthorize("isAuthenticated()")
public class MemberDetailController {
    private final PlatformMembershipService wxUserService;

    private final OrderService orderService;

    @PostMapping("page")
    @ApiOperation("分页列表")
    public ResponseEntity<IPage<WxQueryVO>> page(@RequestBody @Valid WxQueryDTO dto){
        return ResultUtil.success(wxUserService.queryPage(dto));
    }

    @GetMapping("detail")
    @ApiOperation("查看详情")
    public ResponseEntity<StudentDetailVO> detail(String studentId){
        return ResultUtil.success(wxUserService.detailVO(studentId,null,true));
    }

    @GetMapping("detail-d")
    @ApiOperation("查看详情-查看")
    public ResponseEntity<OrderByIdVO> detailD(String orderId){
        return ResultUtil.success(orderService.selectById(orderId));
    }
}
